package com.example.weather;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.weather.ui.notifications.NotificationsFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.example.weather.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        //导航栏跳转
        BottomNavigationView navView = findViewById(R.id.nav_view);
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(binding.navView, navController);

        //接收从收藏过来的数据
        Intent intent=getIntent();
        String cityName=intent.getStringExtra("name");
        String collect=intent.getStringExtra("collect");
        int id=intent.getIntExtra("id",0);

        if (cityName != null) {
            // 创建一个Bundle来传递数据
            Bundle bundle = new Bundle();
            bundle.putString("name", cityName);
            bundle.putString("collect", collect);
            bundle.putInt("id", id);

            // 前往我的天气模块
            Navigation.findNavController(this, R.id.nav_host_fragment_activity_main)
                    .navigate(R.id.navigation_dashboard, bundle);
        }

    }

}